package com.study.controller;

import com.study.model.dto.StudentDataQueryDTO;
import com.study.model.entity.StudentDataDO;
import com.study.result.AjaxResult;
import com.study.service.IStudentDataService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;


/**
 * 学生数据 Controller
 */
@RestController
@RequestMapping("/data")
public class StudentDataController {

    @Resource
    private IStudentDataService studentDataService;

    /**
     * 获取学生数据详情
     */
    @GetMapping("/{id}")
    public AjaxResult get(@PathVariable Long id) {
        return studentDataService.selectStudentDataById(id);
    }

    /**
     * 获取学生数据列表
     */
    @GetMapping("/list")
    public AjaxResult list(StudentDataQueryDTO studentDataQueryDTO) {
        return studentDataService.selectStudentDataList(studentDataQueryDTO);
    }

    /**
     * 新增
     */
    @PostMapping("/add")
    public AjaxResult add(@Validated @RequestBody StudentDataDO studentDataDO) {
        return studentDataService.insertStudentData(studentDataDO);
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    public AjaxResult edit(@Validated @RequestBody StudentDataDO studentDataDO) {
        return studentDataService.updateStudentData(studentDataDO);
    }

    /**
     * 删除
     */
    @PostMapping("/remove")
    public AjaxResult remove(Long id) {
        return studentDataService.deleteStudentDataById(id);
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    public AjaxResult delete(Long[] ids) {
        return studentDataService.deleteStudentDataByIds(ids);
    }

}
